home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Crossword / Source / BackjumpState.m < prev    next >
Text File  |  1995-06-12  |  970b  |  67 lines

  1. /*
  2.  
  3. File BackjumpState.m
  4.  
  5. This state is used for backjumping search.  The state can keep track of a single nogood.
  6.  
  7. */
  8.  
  9. #import <appkit/appkit.h>
  10.  
  11. #import "Backjump.h"
  12.  
  13.  
  14. /* ————————————————————————————————————————————————————————————————————————————  */
  15.  
  16.  
  17. @implementation BackjumpState
  18.  
  19. - squareClass            {    return [BackjumpSquare  class];        }
  20. - wordClass                {    return [BackjumpWord  class];        }
  21. - (BOOL) inNogood        {    return nogood;                        }
  22.  
  23.  
  24. /* ————————————————————————————————————————————————————————————————————————————  */
  25.  
  26.  
  27. - initPuzzle: (id) thePuzzle
  28. {
  29.     [super  initPuzzle: thePuzzle];
  30.     nogoodWords = [[List  alloc]  init];
  31.     nogood = NO;
  32.     
  33.     return self;
  34. }
  35.  
  36.  
  37. - free
  38. {
  39.     [nogoodWords  free];
  40.     return [super  free];
  41. }
  42.  
  43.  
  44. - mustChange: (id) word
  45. {
  46.     [word  mark];
  47.     [nogoodWords  addObject: word];
  48.     nogood = YES;
  49.     
  50.     return self;
  51. }
  52.  
  53.  
  54. - isok
  55. {
  56.     if (nogood)
  57.     {
  58.         [nogoodWords  makeObjectsPerform: @selector(clear)];
  59.         [nogoodWords  empty];
  60.         nogood = NO;
  61.     }
  62.     
  63.     return self;
  64. }
  65.  
  66.  
  67. @end